package com.omega_r.libs.omegarecyclerview.viewpager.default_transformers;

import ohos.agp.components.Component;

/**
 * 由于有些API在鸿蒙中没找到对应的 故此动画空实现
 * setRotationY setCameraDistance
 *
 * @since 2021-04-12
 */
public class CubeOutTransformer extends ABaseTransformer {

    private final int distanceMultiplier;

    public CubeOutTransformer(){
        this(20);
    }

    public CubeOutTransformer(int distanceMultiplier) {
        this.distanceMultiplier = distanceMultiplier;
    }

    @Override
    public boolean isPagingEnabled() {
        return true;
    }

    @Override
    protected void onTransform(Component component, float position) {
        // api 没有
        // component.setCameraDistance((float)(component.getWidth() * this.distanceMultiplier));
         component.setPivotX(position < 0.0F ? (float)component.getWidth() : 0.0F);
         component.setPivotY((float)component.getHeight() * 0.5F);
         component.setRotation(90.0F * position);
    }
}
